<%@ include file="/common/taglibs.jsp"%>

<head>
    <title><fmt:message key="purchaseDetailDetail.title"/></title>
    <meta name="heading" content="<fmt:message key='purchaseDetailDetail.heading'/>"/>
    <meta name="menu" content="RolePurchaser"/>

    <script type="text/javascript" src="<c:url value='/scripts/wz_tooltip.js'/>"></script>

    <script type="text/javascript">
        function TooltipTxt(id){
            var txt = document.getElementById(id).value;
            return txt;
        }

        function changeAction() {
            document.purchaseDetailForm.submit();
        }
    </script>
</head>
<div id="help">
    <h2>
        <a href="<c:url value='helpPurchaseDetailForm.html?decorate=false'/>"
           title="Ayuda Formulario de Detalles Compra de Materia Prima"
           onclick="Modalbox.show(this.href, {title: this.title, width: 600}); return false;">
               <fmt:message key="help"/>
        </a>
    </h2>
</div>
<table>
    <tr>
        <td>
            <s:form id="purchaseDetailForm" name="purchaseDetailForm" action="savePurchaseDetail" method="post" validate="true">
                <s:hidden key="purchaseDetail.id" cssClass="text medium"/>
                <s:hidden key="formatNumberTooltip" id="numberTooltipID" cssClass="text medium"/>
                <s:select list="materials" name="material.id" listKey="id" listValue="fullName" onchange="changeAction()"
                          label="Select Material" headerKey="-1" headerValue="-- Seleccione--" />
                <s:textfield key="material.unitMeasure.description" required="true" cssClass="text medium" disabled="true"/>
                <s:textfield key="purchaseDetail.unitPrice" onmouseover="Tip(TooltipTxt('numberTooltipID'))" onmouseout="UnTip()" required="true" cssClass="text medium" />
                <s:textfield key="purchaseDetail.quantity" required="true" cssClass="text medium" onmouseover="Tip('Este es un mensajito')" onmouseout="UnTip()"/>
                <li class="buttonBar bottom">
                    <c:if test="${(empty purchaseDetail.id) || purchaseDetail.deleted}">
                        <s:submit cssClass="button" method="saveButton" key="button.save" theme="simple"
                                  onmouseover="Tip(TooltipTxt('numberTooltipID'))" onmouseout="UnTip()" />
                    </c:if>
                    <c:if test="${(not empty purchaseDetail.id) && !purchaseDetail.deleted}">
                        <s:submit cssClass="button" method="saveButton" key="button.save" theme="simple"
                        onmouseover="Tip(TooltipTxt('numberTooltipID'))" onmouseout="UnTip()" disabled="true" />
                    </c:if>
                    <c:if test="${(not empty purchaseDetail.id) && purchaseDetail.deleted}">
                        <s:submit cssClass="button" method="delete" key="button.delete" onclick="return confirmDelete('purchaseDetail')" theme="simple"/>
                    </c:if>
                    <c:if test="${empty purchaseDetail.id || !purchaseDetail.deleted}">
                        <s:submit cssClass="button" method="delete" key="button.delete" onclick="return confirmDelete('purchaseDetail')" theme="simple" disabled="true"/>
                    </c:if>
                    <s:submit cssClass="button" method="cancel" key="button.cancel" theme="simple"/>
                </li>
            </s:form>
        </td>
        <td>
            <br><fmt:message key="supplier.fullName"/>: ${ps}<br>
            <fmt:message key="purchase.date"/>: ${pd}<br>
            <fmt:message key="purchase.totalPrice"/>: ${ptp}<br>
        </td>
    </tr>
</table>

<script type="text/javascript">
    Form.focusFirstElement($("purchaseDetailForm"));
</script>